#!/usr/bin/python
# coding: utf-8

from shift_finder_dp import *

if __name__ == '__main__':
    parser = OptionParser(usage='%prog -r REWARD -p PENALTY -l WIN_LENGTH -m MSEQ -s SEQUENCE')
    parser.add_option(Option(
        '-r', '--reward',
        dest = 'reward',
        type = int,
        default = 1,
    ))
    parser.add_option(Option(
        '-p', '--penalty',
        dest = 'penalty',
        type = int,
        default = 3,
    ))
    parser.add_option(Option(
        '-l', '--window-length',
        dest = 'win_length',
        type = int,
        default = 36,
    ))
    parser.add_option(Option(
        '-s', '--sequence',
        dest = 'sequence',
    ))
    parser.add_option(Option(
        '-m', '--m-seq',
        dest = 'm_seq',
    ))
    opts, args = parser.parse_args()
    if opts.win_length % PERIOD != 0:
        print >> sys.stderr, "WIN_LENGTH is not divided by %s" % PERIOD
        sys.exit(1)
    
    base_mx = create_norm_mx(opts.m_seq)
    dp_mx = create_dp_mx(opts, base_mx, opts.sequence)
    max_reward, start_pos, backtrace = create_backtrace(opts, dp_mx)
    print max_reward
    print start_pos, backtrace
    print len(list(uniq(backtrace))) - 1
